import { Text, View, StyleSheet } from 'react-native'
import { Link } from 'expo-router'
import { Login } from '@/apis/user'
import { useEffect } from 'react'

export default function Index() {
	async function handleLogin() {
		console.log('发起登录了')
		const [success, data] = await Login({
			username: 'admin',
			password: '123456',
		})
		if (success) {
			console.log(data)
		}
	}

	useEffect(() => {
		handleLogin()
	}, [])

	return (
		<View style={styles.container}>
			<Text style={styles.text}>Home screen</Text>
			<Link href="/about" style={styles.button}>
				Go to About Screen
			</Link>
		</View>
	)
}

const styles = StyleSheet.create({
	container: {
		flex: 1,
		backgroundColor: '#25292e',
		justifyContent: 'center',
		alignItems: 'center',
	},
	text: {
		color: '#fff',
	},
	button: {
		padding: 10,
		backgroundColor: '#0070f3',
		borderRadius: 5,
		fontSize: 20,
		textDecorationLine: 'underline',
		color: '#fff',
	},
})
